fix(migration): import proxy and general settings from legacy config.
authorCamila Ayres <hello@camilasan.com>
Mon, 17 Mar 2025 18:09:32 +0000 (19:09 +0100)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Tue, 15 Apr 2025 20:47:11 +0000 (20:47 +0000)
Signed-off-by: Camila Ayres <hello@camilasan.com>
src/gui/accountmanager.cpp
src/libsync/clientproxy.cpp
src/libsync/clientproxy.h

index 1ff8dc4fba8f30340ea2c110bf88f4d56e7b3276..cfcce16a48f61ad7f2c19cd13a9f782ef7f0bb9d 100644 (file)
@@ -23,6 +23,7 @@
 #include "libsync/configfile.h"
 #include "libsync/cookiejar.h"
 #include "libsync/theme.h"
+#include "libsync/clientproxy.h"
 
 #include <QSettings>
 #include <QDir>
@@ -60,7 +61,6 @@ constexpr auto networkDownloadLimitSettingC = "networkDownloadLimitSetting";
 constexpr auto networkUploadLimitC = "networkUploadLimit";
 constexpr auto networkDownloadLimitC = "networkDownloadLimit";
 constexpr auto encryptionCertificateSha256FingerprintC = "encryptionCertificateSha256Fingerprint";
-constexpr auto generalC = "General";
 
 constexpr auto dummyAuthTypeC = "dummy";
 constexpr auto httpAuthTypeC = "http";
@@ -82,6 +82,15 @@ constexpr auto maxAccountsVersion = 13;
 constexpr auto maxAccountVersion = 13;
 
 constexpr auto serverHasValidSubscriptionC = "serverHasValidSubscription";
+
+constexpr auto generalC = "General";
+constexpr auto isVfsEnabledC = "isVfsEnabled";
+constexpr auto launchOnSystemStartupC = "launchOnSystemStartup";
+constexpr auto optionalServerNotificationsC = "optionalServerNotifications";
+constexpr auto promptDeleteC = "promptDeleteAllFiles";
+constexpr auto showCallNotificationsC = "showCallNotifications";
+constexpr auto showChatNotificationsC = "showChatNotifications";
+constexpr auto showInExplorerNavigationPaneC = "showInExplorerNavigationPane";
 }
 
 
@@ -251,6 +260,16 @@ bool AccountManager::restoreFromLegacySettings()
         }
     }
 
+    ConfigFile configFile;
+    configFile.setVfsEnabled(settings->value(QLatin1String(isVfsEnabledC)).toBool());
+    configFile.setLaunchOnSystemStartup(settings->value(QLatin1String(launchOnSystemStartupC)).toBool());
+    configFile.setOptionalServerNotifications(settings->value(QLatin1String(optionalServerNotificationsC)).toBool());
+    configFile.setPromptDeleteFiles(settings->value(QLatin1String(promptDeleteC)).toBool());
+    configFile.setShowCallNotifications(settings->value(QLatin1String(showCallNotificationsC)).toBool());
+    configFile.setShowChatNotifications(settings->value(QLatin1String(showChatNotificationsC)).toBool());
+    configFile.setShowInExplorerNavigationPane(settings->value(QLatin1String(showInExplorerNavigationPaneC)).toBool());
+    ClientProxy().setupQtProxyFromSettings(*settings);
+
     // Try to load the single account.
     if (!settings->childKeys().isEmpty()) {
         settings->beginGroup(accountsC);
index 48c277de626d12d166c2cced1b563690fd1abe4d..41fd7f6c206c1cfc53d4b6585234d740df2edbd2 100644 (file)
 #include <QLoggingCategory>
 #include <QUrl>
 #include <QThreadPool>
+#include <QSettings>
+
+namespace {
+    constexpr auto proxyC = "Proxy";
+    constexpr auto proxyTypeC = "Proxy/type";
+    constexpr auto proxyHostC = "Proxy/host";
+    constexpr auto proxyPortC = "Proxy/port";
+    constexpr auto proxyUserC = "Proxy/user";
+    constexpr auto proxyPassC = "Proxy/pass";
+    constexpr auto proxyNeedsAuthC = "Proxy/needsAuth";
+}
 
 namespace OCC {
 
@@ -128,6 +139,23 @@ void ClientProxy::setupQtProxyFromConfig()
     }
 }
 
+void ClientProxy::setupQtProxyFromSettings(const QSettings &settings)
+{
+    if (settings.value(QLatin1String(proxyTypeC)).isNull()) {
+        qCInfo(lcClientProxy) << "No Proxy settings found.";
+        return;
+    }
+
+    OCC::ConfigFile configFile;
+    const auto proxyType = settings.value(QLatin1String(proxyTypeC)).toInt();
+    configFile.setProxyType(proxyType,
+                            settings.value(QLatin1String(proxyHostC)).toString(),
+                            settings.value(QLatin1String(proxyPortC)).toInt(),
+                            settings.value(QLatin1String(proxyNeedsAuthC)).toBool(),
+                            settings.value(QLatin1String(proxyUserC)).toString(),
+                            settings.value(QLatin1String(proxyPassC)).toString());
+}
+
 void ClientProxy::lookupSystemProxyAsync(const QUrl &url, QObject *dst, const char *slot)
 {
     auto *runnable = new SystemProxyRunnable(url);
index 77c1ee80467eddf4f8bab7a80d92a8d5ee973ab3..f1104d85d75b2d5d10e74638c077686207fc8d9b 100644 (file)
@@ -46,6 +46,7 @@ public:
 
 public slots:
     void setupQtProxyFromConfig();
+    void setupQtProxyFromSettings(const QSettings &settings);
 };
 
 class OWNCLOUDSYNC_EXPORT SystemProxyRunnable : public QObject, public QRunnable